package com.itheima.mapper;


//员工信息

import com.itheima.pojo.Emp;
import com.itheima.pojo.EmpQueryParam;
import org.apache.ibatis.annotations.*;

import java.time.LocalDate;
import java.util.List;
import java.util.Map;

@Mapper
public interface EmpMapper {

    //原始分页查询
    //查询总记录数
//    @Select("select count(*) from emp e left join dept d on e.dept_id = d.id;")
//    public Long count();
//
//    //分页查询

//    public List<Emp> list(Integer start,Integer pageSize);

    //@Select("select e.*,d.name deptName from emp e left join dept d on e.dept_id = d.id order by e.update_time")
    //public List<Emp> list(String name, Integer gender, LocalDate begin, LocalDate end);
    public List<Emp> list(EmpQueryParam empQueryParam);

    @Options(useGeneratedKeys = true,keyProperty = "id")//主键返回
    @Insert("insert into emp (username, name, gender, phone, job, salary, image, entry_date, dept_id, create_time, update_time)" +
            "values (#{username},#{name},#{gender},#{phone},#{job},#{salary},#{image},#{entryDate},#{deptId},#{createTime},#{updateTime})")
    void insert(Emp emp);

    //批量删除员工基本信息
    void deleteById(List<Integer> ids);

    //查询员工基本信息
    Emp getByID(Integer id);

    void updateById(Emp emp);
    //统计员工人数
    @MapKey("pos")
    List<Map<String,Object>>countEmpJobData();

    //统计性别人数
    @MapKey("pos")
    List<Map<String,Object>>countEmpGenderData();

    @Select("select id,username,name from emp where username=#{username} and password=#{password}")
    Emp selectByUsernameAndPassword(Emp emp);
}
